package aigle.idm.diagraph.tp4.diagram_default_root.navigator;

import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.ITreePathLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.ViewerLabel;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
import org.eclipse.ui.navigator.ICommonLabelProvider;

/**
 * @generated
 */
public class Tp4NavigatorLabelProvider extends LabelProvider implements
		ICommonLabelProvider, ITreePathLabelProvider {

	/**
	 * @generated
	 */
	static {
		aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
				.getInstance()
				.getImageRegistry()
				.put("Navigator?UnknownElement", ImageDescriptor.getMissingImageDescriptor()); //$NON-NLS-1$
		aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
				.getInstance()
				.getImageRegistry()
				.put("Navigator?ImageNotFound", ImageDescriptor.getMissingImageDescriptor()); //$NON-NLS-1$
	}

	/**
	 * @generated
	 */
	public void updateLabel(ViewerLabel label, TreePath elementPath) {
		Object element = elementPath.getLastSegment();
		if (element instanceof aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorItem
				&& !isOwnView(((aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorItem) element)
						.getView())) {
			return;
		}
		label.setText(getText(element));
		label.setImage(getImage(element));
	}

	/**
	 * @generated
	 */
	public Image getImage(Object element) {
		if (element instanceof aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorGroup) {
			aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorGroup group = (aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorGroup) element;
			return aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().getBundledImage(group.getIcon());
		}

		if (element instanceof aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorItem) {
			aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorItem navigatorItem = (aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorItem) element;
			if (!isOwnView(navigatorItem.getView())) {
				return super.getImage(element);
			}
			return getImage(navigatorItem.getView());
		}

		return super.getImage(element);
	}

	/**
	 * @generated
	 */
	public Image getImage(View view) {
		switch (aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
				.getVisualID(view)) {
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.DocumentationEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Node?http:///tp4-v0?Documentation", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Documentation_2004); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.NomenclatureEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Node?http:///tp4-v0?Nomenclature", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Nomenclature_2002); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.FamilleEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Node?http:///tp4-v0?Famille", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Famille_2003); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.PeripheriqueEditPart.VISUAL_ID:
			return getImage(
					"Navigator?TopLevelNode?http:///tp4-v0?Peripherique", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Peripherique_1002); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.CalculateurEditPart.VISUAL_ID:
			return getImage(
					"Navigator?TopLevelNode?http:///tp4-v0?Calculateur", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Calculateur_1001); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.InfrastructureEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Diagram?http:///tp4-v0?Infrastructure", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Infrastructure_79); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.Famille_nomenclatureEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Link?http:///tp4-v0?Famille?_nomenclature", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Famille_nomenclature_3004); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.Processeur_familleEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Link?http:///tp4-v0?Processeur?_famille", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Processeur_famille_3005); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.InterfaceEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Link?http:///tp4-v0?Interface", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Interface_3001); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.VueDocumentationEditPart.VISUAL_ID:
			return getImage(
					"Navigator?TopLevelNode?http:///tp4-v0?VueDocumentation", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.VueDocumentation_1004); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.ProcesseurEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Node?http:///tp4-v0?Processeur", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Processeur_2001); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.Nomenclature_localisationEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Link?http:///tp4-v0?Nomenclature?_localisation", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Nomenclature_localisation_3003); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.LocalisationEditPart.VISUAL_ID:
			return getImage(
					"Navigator?TopLevelNode?http:///tp4-v0?Localisation", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Localisation_1003); //$NON-NLS-1$
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.CalculateurCoordonneeEditPart.VISUAL_ID:
			return getImage(
					"Navigator?Link?http:///tp4-v0?Calculateur?coordonnee", aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.CalculateurCoordonnee_3002); //$NON-NLS-1$
		}
		return getImage("Navigator?UnknownElement", null); //$NON-NLS-1$
	}

	/**
	 * @generated
	 */
	private Image getImage(String key, IElementType elementType) {
		ImageRegistry imageRegistry = aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
				.getInstance().getImageRegistry();
		Image image = imageRegistry.get(key);
		if (image == null
				&& elementType != null
				&& aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes
						.isKnownElementType(elementType)) {
			image = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes
					.getImage(elementType);
			imageRegistry.put(key, image);
		}

		if (image == null) {
			image = imageRegistry.get("Navigator?ImageNotFound"); //$NON-NLS-1$
			imageRegistry.put(key, image);
		}
		return image;
	}

	/**
	 * @generated
	 */
	public String getText(Object element) {
		if (element instanceof aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorGroup) {
			aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorGroup group = (aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorGroup) element;
			return group.getGroupName();
		}

		if (element instanceof aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorItem) {
			aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorItem navigatorItem = (aigle.idm.diagraph.tp4.diagram_default_root.navigator.Tp4NavigatorItem) element;
			if (!isOwnView(navigatorItem.getView())) {
				return null;
			}
			return getText(navigatorItem.getView());
		}

		return super.getText(element);
	}

	/**
	 * @generated
	 */
	public String getText(View view) {
		if (view.getElement() != null && view.getElement().eIsProxy()) {
			return getUnresolvedDomainElementProxyText(view);
		}
		switch (aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
				.getVisualID(view)) {
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.DocumentationEditPart.VISUAL_ID:
			return getDocumentation_2004Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.NomenclatureEditPart.VISUAL_ID:
			return getNomenclature_2002Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.FamilleEditPart.VISUAL_ID:
			return getFamille_2003Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.PeripheriqueEditPart.VISUAL_ID:
			return getPeripherique_1002Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.CalculateurEditPart.VISUAL_ID:
			return getCalculateur_1001Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.InfrastructureEditPart.VISUAL_ID:
			return getInfrastructure_79Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.Famille_nomenclatureEditPart.VISUAL_ID:
			return getFamille_nomenclature_3004Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.Processeur_familleEditPart.VISUAL_ID:
			return getProcesseur_famille_3005Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.InterfaceEditPart.VISUAL_ID:
			return getInterface_3001Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.VueDocumentationEditPart.VISUAL_ID:
			return getVueDocumentation_1004Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.ProcesseurEditPart.VISUAL_ID:
			return getProcesseur_2001Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.Nomenclature_localisationEditPart.VISUAL_ID:
			return getNomenclature_localisation_3003Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.LocalisationEditPart.VISUAL_ID:
			return getLocalisation_1003Text(view);
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.CalculateurCoordonneeEditPart.VISUAL_ID:
			return getCalculateurCoordonnee_3002Text(view);
		}
		return getUnknownElementText(view);
	}

	/**
	 * @generated
	 */
	private String getDocumentation_2004Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Documentation_2004,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.DocumentationDescriptionEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4009); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getNomenclature_2002Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Nomenclature_2002,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.NomenclatureNameEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4008); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getFamille_2003Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Famille_2003,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.FamilleNomEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4010); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getPeripherique_1002Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Peripherique_1002,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.PeripheriqueNameEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4003); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getCalculateur_1001Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Calculateur_1001,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.CalculateurNomEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4002); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getInfrastructure_79Text(View view) {
		return ""; //$NON-NLS-1$
	}

	/**
	 * @generated
	 */
	private String getFamille_nomenclature_3004Text(View view) {
		return ""; //$NON-NLS-1$
	}

	/**
	 * @generated
	 */
	private String getProcesseur_famille_3005Text(View view) {
		return ""; //$NON-NLS-1$
	}

	/**
	 * @generated
	 */
	private String getInterface_3001Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Interface_3001,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.InterfaceCadenceEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4012); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getVueDocumentation_1004Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.VueDocumentation_1004,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.VueDocumentationNameEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4011); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getProcesseur_2001Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Processeur_2001,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.ProcesseurNomEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4001); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getNomenclature_localisation_3003Text(View view) {
		return ""; //$NON-NLS-1$
	}

	/**
	 * @generated
	 */
	private String getLocalisation_1003Text(View view) {
		IParser parser = aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ParserProvider
				.getParser(
						aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes.Localisation_1003,
						view.getElement() != null ? view.getElement() : view,
						aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
								.getType(aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.LocalisationNameEditPart.VISUAL_ID));
		if (parser != null) {
			return parser.getPrintString(new EObjectAdapter(
					view.getElement() != null ? view.getElement() : view),
					ParserOptions.NONE.intValue());
		} else {
			aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4DiagramEditorPlugin
					.getInstance().logError(
							"Parser was not found for label " + 4005); //$NON-NLS-1$
			return ""; //$NON-NLS-1$
		}
	}

	/**
	 * @generated
	 */
	private String getCalculateurCoordonnee_3002Text(View view) {
		return ""; //$NON-NLS-1$
	}

	/**
	 * @generated
	 */
	private String getUnknownElementText(View view) {
		return "<UnknownElement Visual_ID = " + view.getType() + ">"; //$NON-NLS-1$  //$NON-NLS-2$
	}

	/**
	 * @generated
	 */
	private String getUnresolvedDomainElementProxyText(View view) {
		return "<Unresolved domain element Visual_ID = " + view.getType() + ">"; //$NON-NLS-1$  //$NON-NLS-2$
	}

	/**
	 * @generated
	 */
	public void init(ICommonContentExtensionSite aConfig) {
	}

	/**
	 * @generated
	 */
	public void restoreState(IMemento aMemento) {
	}

	/**
	 * @generated
	 */
	public void saveState(IMemento aMemento) {
	}

	/**
	 * @generated
	 */
	public String getDescription(Object anElement) {
		return null;
	}

	/**
	 * @generated
	 */
	private boolean isOwnView(View view) {
		return aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.InfrastructureEditPart.MODEL_ID
				.equals(aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
						.getModelID(view));
	}

}
